import { reactive } from "vue";
import { getAllAccountTreeApi, getRegistrantTreeApi } from "@/api/financialManagement/receivable/waterVerification";
// import { getListApi as getCustomerApi } from "@/api/managementCenter/customerManagement";
import { getAllCompanyApi } from "@/api/managementCenter/departmentPersonnel";
import { TreeSelect } from "ant-design-vue";
import { getAllCustomerApi } from "@/api/common";
const SHOW_CHILD = TreeSelect.SHOW_CHILD;
export const searchItemList: Array<SuperSearch.SearchItem> = [
  {
    type: "input",
    label: "订单号",
    keyName: "orderNums",
    placeholder: "支持批量(空格/逗号隔开)"
  },
  {
    type: "select",
    label: "核销状态",
    keyName: "chargeOffStateList",
    optConfig: {
      label: "name",
      value: "code"
    },
    attrs: {
      mode: "multiple"
    },
    options: [
      {
        name: "未核销",
        code: 0
      },
      {
        name: "部分核销",
        code: 1
      },
      {
        name: "全部核销",
        code: 2
      }
    ]
  },
  // {
  //   type: "input",
  //   label: "客户名称",
  //   keyName: "customerNames",
  //   placeholder: "支持批量(空格/逗号隔开)"
  // },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "客户简称",
    keyName: "customerIdList",
    optionsRequest: getAllCustomerApi,
    optReqParams: { isFilterChild: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "shortName",
      value: "id"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "cascader",
    label: "收款账户",
    keyName: "accountIdList",
    optConfig: {
      label: "name",
      value: "id",
      children: "deptAccounts"
    },
    optionsRequest: getAllAccountTreeApi,
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.map((t: any) => {
          return {
            name: t.deptName,
            id: t.deptId,
            ...t
          };
        });
      }
    },
    attrs: {
      multiple: true,
      showCheckedStrategy: SHOW_CHILD
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "cascader",
    label: "登记人",
    keyName: "createByList",
    optConfig: {
      label: "name",
      value: "id",
      children: "registerUsers"
    },
    optionsRequest: getRegistrantTreeApi,
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.map((t: any, index: number) => {
          return {
            id: index + 1,
            name: t.positionName,
            ...t
          };
        });
      }
    },
    attrs: {
      multiple: true,
      showCheckedStrategy: SHOW_CHILD
    },
    options: []
  }),
  {
    type: "datetimerange",
    label: "来款时间",
    keyName: "proceedsTime"
  },
  {
    type: "input",
    label: "对账单号",
    keyName: "billNum",
    placeholder: "单个精确搜索"
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "经营单位",
    keyName: "companyIdList",
    optionsRequest: getAllCompanyApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    options: []
  })
];

export const tableColumnMap: Base.GeneraDataType<Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem>> = {
  1: [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "serialNum",
      title: "流水单号",
      minWidth: "150"
    },
    {
      field: "orderNum",
      title: "订单号",
      minWidth: "150"
    },
    {
      field: "shortName",
      title: "客户简称",
      minWidth: "100",
      sortable: true
    },
    {
      field: "customerName",
      title: "客户名称",
      minWidth: "100"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "80",
      sortable: true
    },
    {
      field: "depositPrice",
      title: "来款金额",
      minWidth: "100"
    },
    {
      field: "proceedsAccount",
      title: "收款账户",
      minWidth: "140",
      sortable: true
    },
    {
      field: "payerName",
      title: "来款方名称",
      minWidth: "120"
    },
    {
      field: "proceedsTime",
      title: "来款时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "image",
      title: "来款图片",
      minWidth: "140",
      renderSlot: "image"
    },
    {
      field: "remark",
      title: "来款备注",
      minWidth: "140"
    },
    {
      field: "createName",
      title: "登记人",
      minWidth: "100",
      sortable: true
    },
    {
      field: "createTime",
      title: "登记时间",
      minWidth: "135",
      formatter: "formatDate",
      sortable: true
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "100",
      sortable: true
    },
    {
      field: "action",
      title: "操作",
      minWidth: "140",
      fixed: "right",
      renderSlot: "action"
    }
  ],
  2: [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "serialNum",
      title: "流水单号",
      minWidth: "150"
    },
    {
      field: "orderNum",
      title: "订单号",
      minWidth: "150"
    },
    {
      field: "chargeOffState",
      title: "核销状态",
      minWidth: "100",
      renderSlot: "chargeOffState"
    },
    {
      field: "unChargeOffPrice",
      title: "剩余金额",
      minWidth: "120"
    },
    {
      field: "chargeOffPrice",
      title: "已核销金额",
      minWidth: "120"
    },
    {
      field: "depositPrice",
      title: "来款金额",
      minWidth: "100"
    },
    {
      field: "shortName",
      title: "客户简称",
      minWidth: "100",
      sortable: true
    },
    {
      field: "customerName",
      title: "客户名称",
      minWidth: "100"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "80",
      sortable: true
    },
    {
      field: "proceedsAccount",
      title: "收款账户",
      minWidth: "140",
      sortable: true
    },
    {
      field: "payerName",
      title: "来款方名称",
      minWidth: "120"
    },
    {
      field: "proceedsTime",
      title: "来款时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "image",
      title: "来款图片",
      minWidth: "120",
      renderSlot: "image"
    },
    {
      field: "remark",
      title: "来款备注",
      minWidth: "140"
    },
    {
      field: "createName",
      title: "登记人",
      minWidth: "100",
      sortable: true
    },
    {
      field: "createTime",
      title: "登记时间",
      minWidth: "135",
      formatter: "formatDate",
      sortable: true
    },
    {
      field: "approvalUserName",
      title: "审核人",
      minWidth: "80"
    },
    {
      field: "approvalTime",
      title: "审核时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "100",
      sortable: true
    },
    {
      field: "action",
      title: "操作",
      minWidth: "140",
      fixed: "right",
      renderSlot: "action"
    }
  ],
  3: [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "serialNum",
      title: "流水单号",
      minWidth: "150"
    },
    {
      field: "orderNum",
      title: "订单号",
      minWidth: "150"
    },
    {
      field: "chargeOffState",
      title: "核销状态",
      minWidth: "100",
      renderSlot: "chargeOffState"
    },
    {
      field: "unChargeOffPrice",
      title: "剩余金额",
      minWidth: "120"
    },
    {
      field: "chargeOffPrice",
      title: "已核销金额",
      minWidth: "120"
    },
    {
      field: "depositPrice",
      title: "来款金额",
      minWidth: "100"
    },
    {
      field: "shortName",
      title: "客户简称",
      minWidth: "100",
      sortable: true
    },
    {
      field: "customerName",
      title: "客户名称",
      minWidth: "100"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "80",
      sortable: true
    },
    {
      field: "proceedsAccount",
      title: "收款账户",
      minWidth: "140",
      sortable: true
    },
    {
      field: "payerName",
      title: "来款方名称",
      minWidth: "120"
    },
    {
      field: "proceedsTime",
      title: "来款时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "image",
      title: "来款图片",
      minWidth: "140",
      renderSlot: "image"
    },
    {
      field: "remark",
      title: "来款备注",
      minWidth: "140"
    },
    {
      field: "createName",
      title: "登记人",
      minWidth: "100",
      sortable: true
    },
    {
      field: "createTime",
      title: "登记时间",
      minWidth: "135",
      formatter: "formatDate",
      sortable: true
    },
    {
      field: "approvalUserName",
      title: "审核人",
      minWidth: "80"
    },
    {
      field: "approvalTime",
      title: "审核时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "100",
      sortable: true
    },
    {
      field: "action",
      title: "操作",
      minWidth: "140",
      fixed: "right",
      renderSlot: "action"
    }
  ],
  0: [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "serialNum",
      title: "流水单号",
      minWidth: "150"
    },
    {
      field: "orderNum",
      title: "订单号",
      minWidth: "150"
    },
    {
      field: "chargeOffState",
      title: "核销状态",
      minWidth: "100",
      renderSlot: "chargeOffState"
    },
    {
      field: "unChargeOffPrice",
      title: "剩余金额",
      minWidth: "120"
    },
    {
      field: "chargeOffPrice",
      title: "已核销金额",
      minWidth: "120"
    },
    {
      field: "depositPrice",
      title: "来款金额",
      minWidth: "100"
    },
    {
      field: "shortName",
      title: "客户简称",
      minWidth: "100",
      sortable: true
    },
    {
      field: "customerName",
      title: "客户名称",
      minWidth: "100"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "80",
      sortable: true
    },
    {
      field: "proceedsAccount",
      title: "收款账户",
      minWidth: "140",
      sortable: true
    },
    {
      field: "payerName",
      title: "来款方名称",
      minWidth: "120"
    },
    {
      field: "proceedsTime",
      title: "来款时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "image",
      title: "来款图片",
      minWidth: "140",
      renderSlot: "image"
    },
    {
      field: "remark",
      title: "来款备注",
      minWidth: "140"
    },
    {
      field: "createName",
      title: "登记人",
      minWidth: "100",
      sortable: true
    },
    {
      field: "createTime",
      title: "登记时间",
      minWidth: "135",
      formatter: "formatDate",
      sortable: true
    },
    {
      field: "approvalUserName",
      title: "审核人",
      minWidth: "80"
    },
    {
      field: "approvalTime",
      title: "审核时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "100",
      sortable: true
    },
    {
      field: "action",
      title: "操作",
      minWidth: "140",
      fixed: "right",
      renderSlot: "action"
    }
  ]
};
